home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’95 / Menu Controls / PatternMenu.h < prev    next >
Encoding:
Text File  |  1995-06-24  |  3.5 KB  |  117 lines  |  [TEXT/MPS ]

  1. // Copyright © 1994-95 by Apple Computer, Inc. All rights reserved.
  2. // PatternMenu.h
  3.  
  4. #ifndef __PATTERNMENU__
  5. #define __PATTERNMENU__
  6.  
  7. #ifndef __UVIEW__
  8. #include <UView.h>
  9. #endif
  10.  
  11. #ifndef __UTEAROFFMENUVIEW__
  12. #include "UTearOffMenuView.h"
  13. #endif
  14.  
  15. //--------------------------------------------------------------------------------------------------
  16. // Constants
  17.  
  18. // Patterns custom pulldown menu, menu drawing placement parameters
  19.  
  20. #define kPatternsAcross 4
  21. #define kPatternsDown  10
  22. const short kTotalPatterns = kPatternsAcross * kPatternsDown;
  23.  
  24. #define kWPatternsCell 18
  25. #define kHPatternsCell 14
  26.  
  27. #define kFrameWidth        1
  28. const short kHorizontalFrames    = kPatternsDown - 1;
  29. const short kVerticalFrames     = kPatternsAcross - 1;
  30. const short kTotalFrames        = kHorizontalFrames * kVerticalFrames;
  31.  
  32. const short kWPatternsChoice    = kWPatternsCell * kPatternsAcross + kVerticalFrames;
  33. const short kHPatternsChoice    = kHPatternsCell * kPatternsDown + kHorizontalFrames;
  34.  
  35. const short kNoPatternSelection = -1;
  36.  
  37. //--------------------------------------------------------------------------------------------------
  38.  
  39. void InitPatternsMenu();
  40.     // Initialize the global array of patterns. 
  41.  
  42. //--------------------------------------------------------------------------------------------------
  43. // CLASS TPatternsMenu - the patterns tear-off menu
  44. //--------------------------------------------------------------------------------------------------
  45. class TPatternsMenu : public TTearOffMenuView
  46. {
  47.     MA_DECLARE_CLASS;
  48.  
  49.   public:
  50.     TPatternsMenu();        // Constructor
  51.     void IPatternsMenu(ResNumber menuID);
  52. };
  53.  
  54. //--------------------------------------------------------------------------------------------------
  55. // CLASS TPatternsPalette - the patterns palette used in the tools tear-off menu and
  56. //                            the tools floating window
  57. //--------------------------------------------------------------------------------------------------
  58. class TPatternsPalette : public TView
  59. {
  60.     MA_DECLARE_CLASS;
  61.  
  62.   public:
  63.     TPatternsPalette();        // Constructor
  64.     void IPatternsPalette(TView* itsSuperView);
  65.  
  66.     virtual void DoPostCreate(TDocument* itsDocument);    // Override
  67.  
  68.     void BuildChoiceArray();
  69.     void BuildFramesArray();
  70.  
  71.     // • Screen display
  72.     virtual void DoHighlightSelection(HLState fromHL, HLState toHL); // Override
  73.     virtual void DoSetCursor(const VPoint& localPoint, RgnHandle cursorRegion); // Override
  74.     virtual void Draw(const VRect& area); // Override
  75.  
  76.     void FrameCurrPattern();
  77.         // Frame the currently selected pattern
  78.  
  79.     void SelectNewPattern(short whichPattern);
  80.  
  81.     // • Mousing
  82.     virtual void DoMouseCommand(VPoint& theMouse,
  83.                                 TToolboxEvent* event,
  84.                                 CPoint hysteresis); // Override
  85.     virtual void TrackFeedback(TrackPhase aTrackPhase,
  86.                                const VPoint& anchorPoint,
  87.                                const VPoint& previousPoint,
  88.                                const VPoint& nextPoint,
  89.                                Boolean mouseDidMove,
  90.                                Boolean turnItOn);    // Override
  91.  
  92.     short fSelectedPattern;
  93.     short fCurrPattern;
  94.     short fOldPattern;
  95.  
  96.   private:
  97.     CRect fChoiceArray[kTotalPatterns];    // the rectangle in the view containing a Pattern
  98.     CRect fFramesArray[kTotalFrames];    // the frames in the patterns palette
  99.  
  100.     void TurnOffPattern(CRect patternRect, short whichPattern);
  101.     void TurnOnPattern(CRect patternRect, short whichPattern);
  102. };
  103.  
  104. //----------------------------------------------------------------------------------------
  105.  
  106. short RandomPattern();
  107.  
  108. //----------------------------------------------------------------------------------------
  109. // Externals
  110.  
  111. extern Pattern            gPat[kTotalPatterns];    // array of Patterns
  112.  
  113. extern TPatternsMenu*    gPatternsMenu;
  114. extern TWindow*            gPatternsWindow;
  115.  
  116. #endif
  117.